package com.opentd.npc;

import com.opentd.game.Game;

public class MoveTask {
	int counter = 0;
	int traveledX = 0;
	int traveledY = 0;
	
	public MoveTask(){
		
	}
	
	public void step(Enemy enemy){
		if(counter >= 100 - Game.NPC_MOVE_SPEED){
			if(enemy.direction == Enemy.RIGHT){
				enemy.pixelX++;
				enemy.center.x++;
				traveledX ++;
			}else if(enemy.direction == Enemy.LEFT){
				enemy.pixelX--;
				enemy.center.x--;
				traveledX ++;
			}else if(enemy.direction == Enemy.UP){
				enemy.pixelY--;
				enemy.center.y--;
				traveledY ++;
			}else if(enemy.direction == Enemy.DOWN){
				enemy.pixelY++;
				enemy.center.y++;
				traveledY ++;
			}
			
			if(traveledX == Game.Block.WIDTH){
				if(enemy.direction == Enemy.RIGHT){
					enemy.x++;
				}else if(enemy.direction == Enemy.LEFT){
					enemy.x--;
				}
				traveledX = 0;
			}
			
			if(traveledY == Game.Block.HEIGHT){
				if(enemy.direction == Enemy.UP){
					enemy.y--;
				}else if(enemy.direction == Enemy.DOWN){
					enemy.y++;
				}
				traveledY = 0;
			}
			counter = 0;
		}
		counter++;
	}
	
}
